//
//  MAZiZhiCell.m
//  meiang_edu
//
//  Created by hfcb on 2018/8/1.
//  Copyright © 2018年 com.meiang.meiang_edu. All rights reserved.
//

#import "MAZiZhiCell.h"
#import "MAZiZhiModel.h"

#define ZiZhiCell @"ZiZhiCell"

@interface MAZiZhiCell ()
@property (weak, nonatomic) IBOutlet UIView *containerView;
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *typeLabel;
@property (weak, nonatomic) IBOutlet UILabel *govLabel;
@property (weak, nonatomic) IBOutlet UILabel *termLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UIImageView *typeIcon;
@property (weak, nonatomic) IBOutlet UILabel *cellTypeLabel;

@end

@implementation MAZiZhiCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.containerView.layer.cornerRadius = 4;
    self.containerView.layer.masksToBounds = YES;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] lastObject];
    }
    return self;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    
    MAZiZhiCell *cell = [tableView dequeueReusableCellWithIdentifier:ZiZhiCell];
    if (cell == nil) {
        cell = [[MAZiZhiCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ZiZhiCell];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)setModel:(MAZiZhiModel *)model {
    _model = model;
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMG_OSS,model.ps_id]]];
    self.typeLabel.text = [NSString stringWithFormat:@"证件类型 : %@",model.cetype];
    self.govLabel.text = [NSString stringWithFormat:@"发证机关 : %@",model.gov];
    self.termLabel.text = [NSString stringWithFormat:@"有效期限 : %@",model.cenum];
    self.dateLabel.text = [NSString stringWithFormat:@"更新日期 : %@",model.denabledate];
    
    [self.typeIcon sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMG_OSS,model.image]]];
    
    self.cellTypeLabel.text = model.function_name;
    model.cellHeight = 124;
}

@end
